package com.jackrain.nea.fc.dl.mapper;


import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.HashMap;
import java.util.List;

/**
 * wms出入库回写
 * Mapper
 *
 * @author xuxinshuai
 * @create 2018/05/12
 */
@Mapper
public interface WmsBackWriteMapper {



    @Update("UPDATE DL_B_TRAN SET WMS_IN='Y' WHERE ID IN ( #{ids} ) ")
    int updattraninwmsState(
            @Param("ids") String ids
    );

    @Update("UPDATE DL_B_TRAN SET WMS_OUT='Y' WHERE ID IN ( #{ids} ) ")
    int updattranoutwmsState(
            @Param("ids") String ids
    );

    @Update("UPDATE DL_B_PUR_RET SET WMS_OUT='Y' WHERE ID IN ( #{ids} ) ")
    int updatpurretwmsState(
            @Param("ids") String ids
    );
    @Update("UPDATE DL_B_PUR_IN SET WMS_IN='Y' WHERE ID IN ( #{ids} ) ")
    int updatpurinwmsState(
            @Param("ids") String ids
    );


    @Update("UPDATE DL_B_PUR_ORDER SET WMS_IN='Y' WHERE ID IN ( #{ids} ) ")
    int updatorderwmsState(
            @Param("ids") String ids
    );

    @Update("UPDATE DL_B_TRAN SET WMS_OUT='Y' WHERE ID IN ( #{ids} ) ")
    int updatwmssubmitState(
            @Param("ids") String ids
    );

    @Update("UPDATE DL_B_TRAN SET WMS_IN='Y' WHERE ID IN ( #{ids} ) ")
    int updatwmssendState(
            @Param("ids") String ids
    );

    @Select(" select  t.id AS ID from  DL_B_TRAN t  where t.wms_in = 'N' and t.status='2' and t.SEND_STATUS='2' and t.ACCEPTE_STATUS='1'  and CP_C_DEST_ID IN (206581079021,206265940101,206265940102,206265940103,206265940104,206265940105,206265940107)  AND MODIFY_BILL_NO  IS NULL  ")
    List<HashMap> listData();
    //查ES之后过滤
    @Select(" select count(1) from  DL_B_TRAN t  where t.id= #{ids} AND wms_in = 'N' and status='2' and SEND_STATUS='2' and ACCEPTE_STATUS='1' AND MODIFY_BILL_NO  IS NULL  ")
    Long selectInId(@Param("ids") Long ids);

    @Select("SELECT t.id AS ID  FROM DL_B_TRAN t  WHERE t.wms_out = 'N' AND t.STATUS = '2'  AND t.IS_ADJUST<>2 and t.SEND_STATUS = '1' AND t.CP_C_ORIG_ID in (206581079021,206265940101,206265940102,206265940103,206265940104,206265940105,206265940107) AND MODIFY_BILL_NO  IS NULL ")
    List<HashMap> listTranOutData();
    //查ES之后过滤
    @Select("select count(1) from  DL_B_TRAN t  where t.id= #{ids} AND WMS_OUT = 'N' AND STATUS = '2' AND IS_ADJUST<>2 AND SEND_STATUS = '1' AND MODIFY_BILL_NO  IS NULL")
    Long selectOutId(@Param("ids") Long ids);

    @Select("SELECT  t.id AS ID  FROM DL_B_PUR_ORDER t WHERE t.WMS_IN <> 'Y' and t.`STATUS`=2 and t.CP_C_STORE_ID in (206581079021,206265940101,206265940102,206265940103,206265940104,206265940105,206265940107)")
    List<HashMap> listPurInData();
    //查ES之后过滤
    @Select("select count(1) from  DL_B_PUR_ORDER p  where p.id= #{ids} AND WMS_IN <> 'Y' AND STATUS = '2' ")
    Long selectPurId(@Param("ids") Long ids);



    @Select("SELECT t.id as ID  FROM dl_b_pur_ret t  " +
            "WHERE t.wms_out = 'N' AND t.STATUS = '2'  and t.SEND_STATUS = '2' " +
            "AND t.CP_C_STORE_ID in (206581079021,206265940101,206265940102,206265940103,206265940104,206265940105,206265940107) " +
            "AND MODIFY_BILL_NO  IS NOT NULL")
    List<HashMap> listPurRetData();

    @Select("SELECT t.id as ID  FROM dl_b_pur_in t  " +
            "WHERE t.wms_in = 'N' AND t.STATUS = '2'  and t.ACCEPTE_STATUS = '2' " +
            "AND t.CP_C_STORE_ID in (206581079021,206265940101,206265940102,206265940103,206265940104,206265940105,206265940107) " +
            "AND MODIFY_BILL_NO  IS NOT NULL")
    List<HashMap> listPurInData1();

    @Select("SELECT t.id as ID  FROM DL_B_TRAN t  " +
            "WHERE t.wms_in = 'N' AND t.STATUS = '2'  AND t.IS_ADJUST<>2 and t.ACCEPTE_STATUS = '2' " +
            "AND t.CP_C_DEST_ID in (206581079021,206265940101,206265940102,206265940103,206265940104,206265940105,206265940107) " +
            "AND MODIFY_BILL_NO  IS NOT NULL")
    List<HashMap> listTranInAcceptData();

    @Select("SELECT t.id  as ID FROM DL_B_TRAN t " +
            "WHERE t.wms_out = 'N' AND t.STATUS = '2'  AND t.IS_ADJUST<>2 and t.SEND_STATUS = '2' " +
            "AND t.CP_C_ORIG_ID in (206581079021,206265940101,206265940102,206265940103,206265940104,206265940105,206265940107) " +
            "AND MODIFY_BILL_NO  IS NOT NULL")
    List<HashMap> listTranOutSendData();

}
